package database;

import java.sql.Date;
import java.sql.Time;

/**
 * Classe décrivant les messages
 *
 * @author mariam
 */
public class File extends java.io.File {

    private Profile sender;
    private Profile receiver;
    private Date dateUpload;
    private Time timeUpload;

    public File(String filepath, Profile sender, Profile receiver, Date dateUpload, Time timeUpload) {
        super(filepath);
        this.sender = sender;
        this.receiver = receiver;
        this.dateUpload = dateUpload;
        this.timeUpload = timeUpload;
    }

    public File(String filepath, Profile sender, Profile receiver) {
        super(filepath);
        this.sender = sender;
        this.receiver = receiver;
        this.dateUpload = new Date(new java.util.Date().getTime());
        this.timeUpload = new Time(new java.util.Date().getTime());
    }

    public Profile getSender() {
        return sender;
    }

    public Profile getReceiver() {
        return receiver;
    }

    public Date getDateUpload() {
        return dateUpload;
    }

    public Time getTimeUpload() {
        return timeUpload;
    }

    @Override
    public String toString() {
        String stg;
        stg = "File '" + this.getName() + "' From " + this.sender.getLogin() + "\n";
        stg = stg + "To " + this.receiver.getLogin() + "\n";
        stg = stg + "At " + this.dateUpload.toString() + " - " + this.timeUpload.toString() + "\n";
        return stg;
    }

}
